// $Id$


/**
 * New Game Dialog definition file.
 *
 * @file NewGameDialog.cpp
 * @author Wim Leers
 */


#include "NewGameDialog.h"
#include <QMessageBox>


//----------------------------------------------------------------------------
// Qt: private slots.

void NewGameDialog::CatchAccepted(void) {
	emit NewGame(p1_name->text().toStdString(), p2_name->text().toStdString());
}


//----------------------------------------------------------------------------
// Private methods.

void NewGameDialog::SetupUI(void) {
	this->resize(235, 121);
	this->setContextMenuPolicy(Qt::NoContextMenu);

	buttonBox = new QDialogButtonBox(this);
	buttonBox->setGeometry(QRect(10, 80, 211, 32));
	buttonBox->setOrientation(Qt::Horizontal);
	buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);

	// Labels.
	p1_label = new QLabel(this);
	p1_label->setGeometry(QRect(20, 20, 61, 18));
	p1_label->setText("Speler 1");
	p2_label = new QLabel(this);
	p2_label->setGeometry(QRect(20, 50, 61, 18));
	p2_label->setText("Speler 2");

	// Line edits.
	p1_name = new QLineEdit(this);
	p1_name->setGeometry(QRect(100, 20, 113, 22));
	p2_name = new QLineEdit(this);
	p2_name->setGeometry(QRect(100, 50, 113, 22));

	// Stel focus in.
	// TODO: geef p1_name de focus in het begin.

	// Verbindingen.
	QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
	QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
	QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(CatchAccepted()));
}
